<!DOCTYPE html >
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <title>编辑任务</title>
    <script th:replace="common/head::static"></script>
</head>
<body>
<form class="layui-form layui-form-pane" style="padding: 20px 30px 0 0;">
    <input type="text" name="id" th:value="${sysJob.id}" th:hidden="true">
    <div class="layui-form-item">
        <label class="layui-form-label">任务名</label>
        <div class="layui-input-block">
            <input type="text" name="jobName" th:value="${sysJob.jobName}" lay-verify="required" placeholder="请输入任务名" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">任务分组</label>
        <div class="layui-input-block">
            <input type="text" name="jobGroup" th:value="${sysJob.jobGroup}" lay-verify="required" placeholder="请输入任务分组" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">调用目标</label>
        <div class="layui-input-block">
            <input type="text" name="invokeTarget" th:value="${sysJob.invokeTarget}" lay-verify="required" placeholder="请输入调用目标字符串" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">cron表达式</label>
        <div class="layui-input-block">
            <input type="text" name="cronExpression" th:value="${sysJob.cronExpression}" lay-verify="required" placeholder="请输入cron表达式" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">执行策略</label>
        <div class="layui-input-block">
            <input type="radio" name="misfirePolicy" value="1" title="立即执行" th:checked="${#strings.equals(sysJob.misfirePolicy, '1')}">
            <input type="radio" name="misfirePolicy" value="2" title="执行一次" th:checked="${#strings.equals(sysJob.misfirePolicy, '2')}">
            <input type="radio" name="misfirePolicy" value="3" title="放弃执行" th:checked="${#strings.equals(sysJob.misfirePolicy, '3')}">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">并发执行</label>
        <div class="layui-input-block">
            <input type="radio" name="concurrent" value="0" title="允许" th:checked="${#strings.equals(sysJob.concurrent, '0')}">
            <input type="radio" name="concurrent" value="1" title="禁止" th:checked="${#strings.equals(sysJob.concurrent, '1')}">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="0" title="正常" th:checked="${#strings.equals(sysJob.status, '0')}">
            <input type="radio" name="status" value="1" title="暂停" th:checked="${#strings.equals(sysJob.status, '1')}">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="sysJobUpdate">确认</button>
            <button type="button" class="layui-btn layui-btn-primary" id="sysJobUpdateCancel">取消</button>
        </div>
    </div>
</form>
<script th:src="@{/common/js/common.js}"></script>
<script>
    layui.use(['form'], function () {
        const $ = layui.jquery,
            layer = layui.layer,
            form = layui.form;
        form.render();

        form.on('submit(sysJobUpdate)', function (obj) {
            Common.ajaxPutJSON(ctx + "/sysJob/update", JSON.stringify(obj.field), function (res){
                if (res.value === 200) {
                    layer.msg(res.message, {icon: 1, time: 1000}, function () {
                        parent.$('#sysJobSearchBtn').click();
                        Common.closeFrame();
                    });
                } else {
                    layer.msg(res.message, {icon: 2, time: 2000});
                }
            })
            return false;
        });

        $("#sysJobUpdateCancel").on('click', function () {
            parent.$('#sysJobSearchBtn').click();
            Common.closeFrame();
        });
    });
</script>
</body>
</html>